#include"string.h"


namespace refrain
{
	void test_string01()
	{
		//std::string s2;
		string s1("hello world");
		cout << s1.c_str() << endl;
		s1.push_back('x');
		cout << s1.c_str() << endl;

		string s2("hello world");
		s2.append("xxxxx");
		cout << s2.c_str() << endl;
	}
	void test_string02()
	{
		string s1("hello world");
		/*s1 += 'x';
		cout << s1.c_str() << endl;
		s1 += "hi Gan";
		cout << s1.c_str() << endl;*/

		for (int i = 0; i < s1.size(); i++)
		{
			cout << s1[i] << " ";
		}
		cout << endl;
	}
	void test_string03()
	{
		string s1("hello world");
		auto it = s1.begin();
		while (it != s1.end())
		{
			cout << *it << " ";
			it++;
		}
		cout << endl;
		for (auto ch : s1)
		{
			cout << ch << " ";
		}
		cout << endl;

	}
	void test_string04()
	{
		const string s("hello world");
		for (int i = 0; i < s.size(); i++)
		{
			cout << s[i] << " ";
		}
		cout << endl;
	}
	void test_string05()
	{
		string s("hello world");
		s.insert(0, 'x');
		cout << s.c_str() << endl;
		s.insert(3, 'f');
		cout << s.c_str() << endl;

	}
	void test_string06()
	{
		string s("hello world");
		s.insert(0, "xxxx");
		cout << s.c_str() << endl;
		s.insert(3, "gan lin");
		cout << s.c_str() << endl;

	}
	void test_string07()
	{
		string s1("hello world");
		cout << s1.c_str() << endl;
		s1.erase(3);
		cout << s1.c_str() << endl;
		string s2("hello world");
		cout << s2.c_str() << endl;
		s2.erase(3,4);
		cout << s2.c_str() << endl;

	}
	void test_string08()
	{
		string s1("hello world");
		char ch; cin >> ch;
		s1[s1.find(ch)] = 'g';
		cout << s1.c_str() << endl;
	}
	void test_string09()
	{
		string s1("hello world");
		cout << s1.find("ll") << endl;
	}
	void test_string10()
	{
		string s1("hello world");
		string s2 = s1.substr(3);
		cout << s2.c_str() << endl;
		string s3 = s1.substr(3,2);
		cout << s3.c_str() << endl;

	}
	void test_string11()
	{
		string s3("hello world");
		string s4 = s3.substr(6);
		cout << s4.c_str() << endl;

		string s6 = s3.substr(6, 3);
		cout << s6.c_str() << endl;
	}
	void test_string12()
	{
		string s1 = "hello world";
		cout << s1 << endl;
		s1 += '\0';
		s1 += "xxxx";
		cout << s1 << endl;
		cout << s1.c_str() << endl;

	}

	void test_string13()
	{
		string s;
		cin >> s;
		cout << s;
		string s1("hello");
		cin >> s1;
		cout << s1;
	}
}
int main()
{
	
	refrain::test_string13();
	return 0;
}